package com.qiangesoft.blog.controller.manage;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.qiangesoft.blog.common.annotation.OperationLog;
import com.qiangesoft.blog.common.mvc.PageQuery;
import com.qiangesoft.blog.common.mvc.PageResultVO;
import com.qiangesoft.blog.common.result.ResponseResult;
import com.qiangesoft.blog.core.entity.BlogLeaveMessage;
import com.qiangesoft.blog.core.service.IBlogLeaveMessageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 留言 前端控制器
 * </p>
 *
 * @author qiange
 */
@RestController
@RequestMapping("/system/message")
@Api(tags = "留言管理-接口")
@RequiredArgsConstructor
public class BlogLeaveMessageController {

    private final IBlogLeaveMessageService messageService;

    @GetMapping(value = "/list")
    @ApiOperation(value = "留言列表")
    public PageResultVO<BlogLeaveMessage> list(@Validated PageQuery pageQuery, String name) {
        return messageService.listMessage(pageQuery, name);
    }

    @RequestMapping(value = "/passBatch", method = RequestMethod.POST)
    @OperationLog(value = "批量通过")
    @ApiOperation(value = "批量通过", httpMethod = "POST", response = ResponseResult.class, notes = "批量通过")
    public ResponseResult passBatch(@RequestBody List<Long> ids) {
        return messageService.passBatch(ids);
    }


    @RequestMapping(value = "/remove", method = RequestMethod.DELETE)
    @OperationLog(value = "删除留言")
    @ApiOperation(value = "删除留言", httpMethod = "DELETE", response = ResponseResult.class, notes = "删除留言")
    public ResponseResult deleteMessageById(int id) {
        return messageService.deleteMessageById(id);
    }


    @RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE)
    @OperationLog(value = "批量删除留言")
    @ApiOperation(value = "批量删除留言", httpMethod = "DELETE", response = ResponseResult.class, notes = "批量删除留言")
    public ResponseResult deleteBatch(@RequestBody List<Long> ids) {
        return messageService.deleteBatch(ids);
    }
}

